Skip to content

Include cross-parameter violations in hasErrors() and getAllErrors()#36672

Closed
tianhaocui wants to merge 1 commit into
spring-projects:mainfrom
tianhaocui:fix-cross-parameter-validation-errors
Closed

Include cross-parameter violations in hasErrors() and getAllErrors()#36672
tianhaocui wants to merge 1 commit into
spring-projects:mainfrom
tianhaocui:fix-cross-parameter-validation-errors

Conversation

@tianhaocui
Copy link
Copy Markdown
Contributor

Closes #36666

MethodValidationResult.hasErrors() only checked getParameterValidationResults(), completely ignoring cross-parameter constraint violations. Similarly, getAllErrors() only collected errors from per-parameter results.

When adapt-constraint-violations is enabled, cross-parameter violations are stored separately via getCrossParameterValidationResults(). This caused hasErrors() to return false and getAllErrors() to return an empty list even when cross-parameter violations were present, effectively swallowing these errors.

Changes:

  • hasErrors() now also checks getCrossParameterValidationResults()
  • getAllErrors() now includes cross-parameter errors via Stream.concat

MethodValidationResult.hasErrors() only checked
getParameterValidationResults(), ignoring cross-parameter constraint
violations entirely. Similarly, getAllErrors() only collected errors
from per-parameter results.

When adapt-constraint-violations is enabled, cross-parameter violations
are stored separately via getCrossParameterValidationResults(). Both
hasErrors() and getAllErrors() now include these results so that
cross-parameter constraint violations are properly surfaced.

Closes spring-projects#36666

Signed-off-by: cuitianhao <54015884+tianhaocui@users.noreply.github.com>
@tianhaocui tianhaocui force-pushed the fix-cross-parameter-validation-errors branch from 6e239f0 to 7aca8be Compare April 19, 2026 09:51
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 19, 2026
@rstoyanchev
Copy link
Copy Markdown
Contributor

Thanks for the change but this issue requires a deeper review, and is not open for contribution.

@rstoyanchev rstoyanchev added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: declined A suggestion or change that we don't feel we should currently apply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MethodValidationAdapter ignores cross-parameter violations when adapt-constraint-violations is enabled

3 participants